package org.spolo.android.shape;

import org.spolo.android.nodetree.Vcanvas;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;

public class TextRect extends Vcanvas {
	private RectF rectf;
	private String text;
	private Paint backPaint;
	private Paint forePaint;

	public TextRect(String text, float left, float top, float right,
			float bottom) {
		this.text = text;
		rectf = new RectF(left, top, right, bottom);
		backPaint = new Paint();
		backPaint.setColor(Color.CYAN);
		forePaint = new Paint();
		forePaint.setColor(Color.RED);
		// 设置触摸区域
		setDirtyRect(left, top, right, bottom);
	}

	/**
	 * 获取背景paint对象
	 */
	public Paint getBackPaint() {
		return this.backPaint;
	}

	/**
	 * 获取前景paint对象
	 */
	public Paint getForePaint() {
		return this.forePaint;
	}

	@Override
	public void drawSelfImplement(Canvas canvas) {
		super.drawSelfImplement(canvas);
		canvas.drawRect(this.rectf, this.backPaint);
		canvas.drawText(text, rectf.left + 10, rectf.top + 15, this.forePaint);
	}

}
